//
//  Operation.h.m
//  Yueba
//
//  Created by Gan LL on 12-10-16.
//
//

#import "Operation.h"

@implementation Operation


- (id)initWithData:(id)data delegate:(id <OperationDelegate>)theDelegate
{
    self = [super init];
    if (self != nil)
    {
        operationData = [data retain];
        _delegate = theDelegate;
    }
    return self;
}

// -------------------------------------------------------------------------------
//	dealloc:
// -------------------------------------------------------------------------------
- (void)dealloc
{
    [operationData release];
    [super dealloc];
}

// -------------------------------------------------------------------------------
//	main:
//  Given data to parse, use NSXMLParser and process all the top paid apps.
// -------------------------------------------------------------------------------
- (void)main
{
	NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
    if (operationData != nil && _delegate != nil) {
        if ([_delegate respondsToSelector:@selector(processData:)]) {
            [_delegate processData:operationData];
        }
    }
	[pool drain];
}

@end
